package catch

import (
	"baby/appcoing"
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
)

var Ctx = context.Background()
var Rdb *redis.Client

func Exam() {
	aa := appcoing.Appdata.Redis
	addr := fmt.Sprintf("%s:%d", aa.Host, aa.Port)
	Rdb = redis.NewClient(&redis.Options{
		Addr:     addr,
		Password: aa.Password, // no password set
		DB:       0,           // use default DB
	})

	err := Rdb.Set(Ctx, "key", "value", 0).Err()
	if err != nil {
		panic(err)
	}
	fmt.Println("redis连接成功")
}
